using MinoChat.Ui.Controls;
using MinoChat.Ui.Enums;
using System.Windows;

namespace MinoChat.Ui.Services;

public class SnackbarService
{   
    //Snackbar控件关联到服务中
    private Snackbar? _snackbar;
    public void RegisterSnackbar(Snackbar snackbar) => _snackbar = snackbar;
    public void Show(string title, string message, ImageType type = ImageType.Info, int duration = 3000)
    {
        //必须在UI线程上更新UI，否则会闪退
        Application.Current.Dispatcher.Invoke(() =>
        {
            _snackbar?.Show(title, message, type, duration);
        });
    }
    public void Show(string message) => Show(string.Empty, message);
}
